﻿fifachamps.core.access.push("tournament");

fifachamps.tournament = {
    initialize: function () {
        
        var store = Ext.create('Ext.data.TreeStore', {
//            root: {
//                expanded: true,
//                children: [
//                    { text: "detention", leaf: true },
//                    { text: "homework", expanded: true, children: [
//                        { text: "book report", leaf: true },
//                        { text: "alegrbra", leaf: true}
//                    ] },
//                    { text: "buy lottery tickets", leaf: true }
//                ]
//            },
            proxy: { 
                type: 'ajax',
                url: '/proxy.ashx',
                extraParams: { cmd: 'get_tournaments' }
            }
        });

        var tournament_panel = new Ext.Panel({
            id: 'PNL_tournament',
            title: 'Tournament',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items: [{
                title: 'Menu',
                tbar: [{
                    xtype: 'button',
                    text: 'Add Tournament',
                    iconCls: 'icon-soccer',
                    tooltip: 'Add Tournament'
                }],
                xtype: 'treepanel',
                store: store,
                rootVisible: false,
                flex: 1
            }, {
                xtype: 'tabpanel',    
                id: 'TABPNL_tournamentinfo',            
                flex: 2,
                items: [{
                    xtype: 'panel',
                    title: 'Panel 1',
                    flex: 1
                }, {
                    xtype: 'panel',
                    title: 'Panel 2',
                    flex: 1
                }]
            }]
        });

        fifachamps.core.tabpanel.add_tab(tournament_panel);
    },
    load_tournament: function(params) {
        //opens new tournament info panel
        var tornyID = params.ID;
        var tornyName = params.Name;
        var panel = new Ext.panel({
            id: tornyID,
            title: tornyName,
            layout: {
                type: 'vbox'                
            },
            items: [{
                xtype: 'panel',
                layout: 'column',
                flex: 1,
                items: [{
                    xtype: 'panel',
                    layout: 'form'
                }, {
                    xtype: 'panel'
                }]
            }, {
                xtype: 'tabpanel',
                flex: 2                
            }]
        });
    }
};